package com.elitecore.daoImpl;

import java.util.List;

import org.apache.log4j.Logger;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.elitecore.beans.CountryMasterBean;
import com.elitecore.dao.CountryDAO;


@Repository("countryDAOImpl") 
public class CountryDAOImpl implements CountryDAO
{
	private String MODULE =  "CountryDAOImpl";
	private static org.apache.log4j.Logger log	= Logger.getLogger(AuthenticateDAOImpl.class);
	
	@Autowired
	private SessionFactory sessionFactory;
	
	public List<CountryMasterBean> getAllCountry()
	{
		String METHOD = "getAllCountry";
		log.info(" in "+METHOD+" of "+MODULE);
		
		List<CountryMasterBean> countryList = null;
		
		try
		{
			Session session = sessionFactory.getCurrentSession();
			String hql = "from CountryMasterBean where status = 1";
			Query query = session.createQuery(hql);
			countryList = (List<CountryMasterBean>) query.list();
			
		}catch(Exception e)
		{
			countryList = null;
			log.info(" Exception in "+METHOD+" of "+MODULE+e,e);
		}
		return countryList;
	}
}